package tingshu.view_object;


import lombok.Data;
import tingshu.data_object.AlbumDO;
import tingshu.data_object.TrackDO;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class BindView {
    public static class TrackView{
        public Integer tid;
        public String title;

        public TrackView(Integer tid, String title) {
            this.tid = tid;
            this.title = title;
        }
    }

    public UserVO currentUser;
    public Integer aid;
    public String title;
    public List<TrackView> trackList;

    public BindView(UserVO currentUser, AlbumDO albumDO, List<TrackDO> trackDOList) {
        this.currentUser = currentUser;
        this.aid = albumDO.aid;
        this.title = albumDO.title;
        trackList = new ArrayList<>();
        for (TrackDO trackDO : trackDOList) {
            trackList.add(new TrackView(
                    trackDO.tid,
                    trackDO.title
            ));
        }

//        {
//            this.trackList = trackDOList.stream().map(d -> new TrackView(d.tid, d.title)).collect(Collectors.toList());
//        }
    }
}
